using System;
using System.Runtime.Serialization;
using EnvDTE;
using VSSDKAssist.Assets.References.Base;

namespace VSSDKAssist.Assets.References.VisualStudio
{
    /// <summary>
    /// UnboundReference for a project
    /// </summary>
    [Serializable]
    public class ProjectReference : RecipeReferenceBase
    {
        /// <summary>
        /// Constructor of the <see cref="ProjectItemReference"/> that must specify the 
        /// recipe name that will be used by the reference
        /// </summary>
        /// <param name="recipe"></param>
        public ProjectReference(string recipe)
            : base(recipe)
        {
        }

        /// <summary>
        /// See <see cref="P:Microsoft.Practices.RecipeFramework.IAssetReference.AppliesTo"/>.
        /// </summary>
        /// <value></value>
        public override string AppliesTo
        {
            get { return Properties.Resources.ProjectReference; }
        }

        /// <summary>
        /// Performs the validation of the item passed as target
        /// Returns true if the reference is allowed to be executed in the target
        /// that is if the target is a <see cref="ProjectItem"/> file.
        /// </summary>
        /// <param name="target"></param>
        /// <returns></returns>
        public override bool IsEnabledFor(object target)
        {
            Project project = target as Project;

            if(project != null)
            {
                return true;
            }

            return false;
        }

        #region ISerializable Members

        /// <summary>
        /// Initializes a new instance of the <see cref="T:ProjectItemReference"/> class.
        /// </summary>
        /// <param name="info">The <see cref="T:System.Runtime.Serialization.SerializationInfo"/> that holds the serialized object data about the reference.</param>
        /// <param name="context">The <see cref="T:System.Runtime.Serialization.StreamingContext"/> that contains contextual information about the source or destination.</param>
        [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1062:ValidateArgumentsOfPublicMethods")]
        protected ProjectReference(SerializationInfo info, StreamingContext context)
            : base(info, context)
        {
        }
        #endregion ISerializable Members
    }
}